/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package helloscala.practise.chapter2

import java.util.ArrayList
import helloscala.practise.ChapterEntry

object Chapter2Entry extends ChapterEntry {
  def runTests: Unit = {
    testFlexyImport
  }

  def testFlexyImport: Unit = {
    FlexyImport.closureImport
  }

  def testOption: Unit = {
    OptionSomeNone.avoidNull
  }

  def testTupleShower: Unit = {
    TupleShower.createTuple
  }

  def testStringLiteral: Unit = {
    println(StringLiteral.createMultiLineString1)
    println(StringLiteral.createMultiLineString2)
  }

  def testOptionalUserProfileInfo() {
    println(OptionalUserProfileInfo.unkownAge)
    println
    println(new OptionalUserProfileInfo(age = 12))
    println(new OptionalUserProfileInfo("Here", age = 12))
    //when parameter order has been overidden, all params must point out the name
    //println(new OptionalUserProfileInfo(age = 12, "www.here.com"))
    println(new OptionalUserProfileInfo(age = 12, webSite = "www.here.com"))
  }

  def testFractorialUtil() {
    println(FractorialUtil.fractorial(5))
  }

  def testJavaCollection = {
    JavaCollection.createMaps
    JavaCollection.createScalaMap
  }

  def testReturnType = {
    println(ReturnType.returnString1)

    println(ReturnType.returnString2(List("I", "am", "Jeff")))
    println(ReturnType.returnString2(List()))

    println(ReturnType.returnString3(new ArrayList[String]))
    //val list: List[String] = ReturnType.returnString3(new ArrayList[String])) //error

    val list: Array[Object] = ReturnType.returnString4(new ArrayList[String])
    println(list)
  }
}
